Skip to content

Fix LD_PRELOAD namespace restriction using memfd#553

Merged
JingMatrix merged 1 commit intomasterfrom
dex2oat
Mar 6, 2026
Merged

Fix LD_PRELOAD namespace restriction using memfd#553
JingMatrix merged 1 commit intomasterfrom
dex2oat

Conversation

@JingMatrix
Copy link
Copy Markdown
Owner

The Android dynamic linker (Bionic) restricts loading libraries from unauthorized paths via LD_PRELOAD. This causes the linker to reject the hook library with a "not accessible for the namespace" fatal error.

To bypass this restriction, we exploit a fallback in Bionic that explicitly skips the namespace accessibility check for files located on tmpfs. We use memfd_create to create an anonymous tmpfs-backed file descriptor, copy the library into it using sendfile, and pass the new memfd to LD_PRELOAD instead.

Reference: function load_library in https://cs.android.com/android/platform/superproject/main/+/main:bionic/linker/linker.cpp

@JingMatrix JingMatrix linked an issue Mar 6, 2026 that may be closed by this pull request
1 task
The Android dynamic linker (Bionic) restricts loading libraries from unauthorized paths via LD_PRELOAD. This causes the linker to reject the hook library with a "not accessible for the namespace" fatal error.

To bypass this restriction, we exploit a fallback in Bionic that explicitly skips the namespace accessibility check for files located on tmpfs. We use `memfd_create` to create an anonymous tmpfs-backed file descriptor, copy the library into it using `sendfile`, and pass the new memfd to LD_PRELOAD instead.

Reference: function `load_library` in https://cs.android.com/android/platform/superproject/main/+/main:bionic/linker/linker.cpp
@JingMatrix JingMatrix merged commit 6fc25c6 into master Mar 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSPOSED BREAKS DEX2OAT IN A10

1 participant